package com.bw.zg3park2212.device

import androidx.lifecycle.MutableLiveData
import com.bw.base.entity.DeviceAddParam
import com.bw.base.entity.DeviceEntity
import com.bw.base.entity.DeviceEntityItem
import com.bw.base.mvvm.BaseViewModel
import com.bw.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class DeviceViewModel @Inject constructor(val apiServise: ApiService): BaseViewModel(){
    val deviceSuccse=MutableLiveData<DeviceEntity>()
    fun getDevice(){
        httpRequst(
            {apiServise.getDevice()},
            deviceSuccse::postValue
        )
    }
    val deviceaddress=MutableLiveData<DeviceEntity>()
    fun getDeviceAddress(keyword:String){
        httpRequst(
            {apiServise.getDeviceAddress(keyword)},
            deviceaddress::postValue
        )
    }
    val devicename=MutableLiveData<DeviceEntity>()
    fun getDeviceName(keyword:String){
        httpRequst(
            {apiServise.getDeviceName(keyword)},
            devicename::postValue
        )
    }
    val devicedel=MutableLiveData<Boolean>()
    fun getDeviceDel(id:Int){
        httpRequst(
            {apiServise.getDeviceDel(id)},
            devicedel::postValue
        )
    }
    val devicexiangSuccse=MutableLiveData<DeviceEntityItem>()
    fun getDeviceXiang(id:Int){
        httpRequst(
            {apiServise.getDeviceXiang(id)},
            devicexiangSuccse::postValue
        )
    }
    val deviceupdateSuccse=MutableLiveData<DeviceEntityItem>()
    fun getDeviceUpdate(id:Int,deviceAddParam: DeviceAddParam){
        httpRequst(
            {apiServise.getDeviceUp(id,deviceAddParam)},
            deviceupdateSuccse::postValue)
    }
}